#include "mysig.h"

SigFunPtr signal(int sig, SigFunPtr handler);
static void handle_sig(int sig);

int main() {
    if (signal(SIGUSR1, handle_sig) == SIG_ERR) {
        printf("error when setup handler\n");
        exit(EXIT_FAILURE);
    }
    if (signal(SIGUSR2, handle_sig) == SIG_ERR) {
        printf("error when setup handler\n");
        exit(EXIT_FAILURE);
    }

    while (1) {
        pause();
    }

    return EXIT_SUCCESS;
}

static void handle_sig(int sig) {
    switch (sig) {
    case SIGUSR1:
        printf("receive SIGUSR1\n");
        break;
    case SIGUSR2:
        printf("receive SIGUSR2\n");
        break;
    }
}
